﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminPage/Admin.master" AutoEventWireup="true" CodeFile="AddSchoolInfo.aspx.cs" Inherits="AdminPage_AddSchoolInfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style1 {
            width: 70%;
        }
        .style2
        {
            height: 20px;
            width: 596px;
        }
        .style1 td
        {
            padding:8px;
        }
        .style4
        {
            height: 20px;
            width: 158px;
        }
        #left
        {
            float:left;
            padding:10px;
        }
         #left li
        {
           
            padding:10px;
        }
        #right
        {
            float:left;
            padding:10px;
        }  
        .style7
        {
            width: 158px;
        }
        .style8
        {
            width: 596px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


<div >
<div id="left">
    <ul>
    <li>
        <asp:LinkButton ID="LinkButton_addschool" runat="server" 
            onclick="LinkButton_addschool_Click">学校数据维护</asp:LinkButton></li>
    <li></li>
    <li></li>
    <li></li>
    </ul>
</div>
<div id="right">
    
    <asp:Panel ID="Panel_addschool" runat="server">
     <ContentTemplate>
    <table class="style1">
        <tr>
            <td class="style7">
                所在省</td>
            <td class="style8">
                <asp:DropDownList ID="DropDownList_province" runat="server" AutoPostBack="True" 
                    DataSourceID="SqlDataSource_province" DataTextField="province" 
                    DataValueField="ProID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource_province" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                    SelectCommand="SELECT * FROM [ProvinceTable]"></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style4">
                所在市</td>
            <td class="style2">
                <asp:DropDownList ID="DropDownList_city" runat="server" 
                    DataSourceID="SqlDataSource_city" DataTextField="city" 
                    DataValueField="CityID" AutoPostBack="True">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource_city" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                    SelectCommand="SELECT DISTINCT * FROM [CityTable] WHERE ([ProID] = @ProID)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList_province" Name="ProID" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
                </td>
        </tr>
        <tr>
            <td class="style7">
                所在县/区</td>
            <td class="style8">
                <asp:DropDownList ID="DropDownList_county" runat="server" 
                    DataSourceID="SqlDataSource_county" DataTextField="county" 
                    DataValueField="CountyId" AutoPostBack="True">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource_county" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                    SelectCommand="SELECT * FROM [CountyTable] WHERE ([CityID] = @CityID)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList_city" Name="CityID" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style7">
                学校名称</td>
            <td class="style8">
                <asp:TextBox ID="TextBox_schoolname" runat="server" Height="80px" Width="162px" 
                    TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                <asp:Button ID="Button_school" runat="server" onclick="Button_school_Click" 
                    Text="添加" />
            </td>
        </tr>
        <tr>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                所选市的学校列表：</td>
        </tr>
        <tr>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                    AutoGenerateColumns="False" DataKeyNames="SchoolId" 
                    DataSourceID="SqlDataSource_schoolTable">
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        <asp:BoundField DataField="SchoolId" HeaderText="学校ID" InsertVisible="False" 
                            ReadOnly="True" SortExpression="SchoolId" />
                        <asp:BoundField DataField="SchoolName" HeaderText="学校名称" 
                            SortExpression="SchoolName" />
                        <asp:BoundField DataField="CountyId" HeaderText="所属县/区ID" 
                            SortExpression="CountyId" Visible="False" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource_schoolTable" runat="server" 
                    ConflictDetection="CompareAllValues" 
                    ConnectionString="<%$ ConnectionStrings:ConnString %>" 
                    DeleteCommand="DELETE FROM [SchoolTable] WHERE [SchoolId] = @original_SchoolId AND [SchoolName] = @original_SchoolName AND (([CountyId] = @original_CountyId) OR ([CountyId] IS NULL AND @original_CountyId IS NULL))" 
                    InsertCommand="INSERT INTO [SchoolTable] ([SchoolName], [CountyId]) VALUES (@SchoolName, @CountyId)" 
                    OldValuesParameterFormatString="original_{0}" 
                    SelectCommand="SELECT SchoolId, SchoolName, CountyId FROM SchoolTable WHERE (CountyId IN (SELECT CountyId FROM CountyTable WHERE (CityID = @cityID)))" 
                    
                    UpdateCommand="UPDATE [SchoolTable] SET [SchoolName] = @SchoolName, [CountyId] = @CountyId WHERE [SchoolId] = @original_SchoolId AND [SchoolName] = @original_SchoolName AND (([CountyId] = @original_CountyId) OR ([CountyId] IS NULL AND @original_CountyId IS NULL))">
                    <DeleteParameters>
                        <asp:Parameter Name="original_SchoolId" Type="Int32" />
                        <asp:Parameter Name="original_SchoolName" Type="String" />
                        <asp:Parameter Name="original_CountyId" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="SchoolName" Type="String" />
                        <asp:Parameter Name="CountyId" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList_city" Name="cityID" 
                            PropertyName="SelectedValue" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="SchoolName" Type="String" />
                        <asp:Parameter Name="CountyId" Type="Int32" />
                        <asp:Parameter Name="original_SchoolId" Type="Int32" />
                        <asp:Parameter Name="original_SchoolName" Type="String" />
                        <asp:Parameter Name="original_CountyId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
     </ContentTemplate>
    </asp:Panel>
    </div>
    </div>
</asp:Content>

